/*********************************************************************************
 *      Copyright:  (C) 2022 Zhang Changxing<ZhangChangxingVIP@163.com>
 *                  All rights reserved.
 *
 *       Filename:  packinfo.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(04/14/2022)
 *         Author:  Zhang Changxing <ZhangChangxingVIP@163.com>
 *      ChangeLog:  1, Release initial version on "04/14/2022 08:36:37 PM"
 *                 
 ********************************************************************************/

#include "main.h"

 /*The received string is parsed and stored in the pack_info structure*/
int data_segmentation(char *buf, pack_info_t *pack_info)
{
    char    *buftok[3];
    char    *p = NULL;
    int     j =0;

	if((NULL == buf)||(NULL == pack_info))
	{
		log_error("The data_segmentation() argument incorrect!\n");
        return -1;
	}

    log_debug("Read data from client:%s\n", buf);
    p = strtok(buf, "/");
    while (p)
    {
        buftok[j] = p;
        ++j;
        p = strtok(NULL, "/");
    }

    strcpy(pack_info->devid, buftok[0]);
	strcpy(pack_info->strtime, buftok[1]);
	pack_info->temper = atof(buftok[2]);

    return 0;
}